package com.hdey.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Component
@RestControllerAdvice
@Slf4j
public class SystemExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public Result catchException(RuntimeException e){
        Result result=new Result();
        result.setCode(-1);
        result.setMsg("查询错误，请联系管理员");
        log.error("查询错误，请联系管理员",e);
        return result;
    }
}
